import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';
import { MainpageComponent } from './main/mainpage/mainpage.component';
import { SearchpageComponent } from './main/searchpage/searchpage.component';
import { IdealmessageComponent } from './showmessage/idealmessage/idealmessage.component';
import { SuitablemessageComponent } from './showmessage/suitablemessage/suitablemessage.component';
import { ThebestmessageComponent } from './showmessage/thebestmessage/thebestmessage.component';
import { ShowmessageComponent } from './showmessage/showmessage.component';
import { ErrorpageComponent } from './errorpage/errorpage.component';
import { LoginComponent } from './login/login.component';
import { RegisterComponent } from './register/register.component';

 
const routes: Routes = [
    {
      path: 'search',
      component: SearchpageComponent
    },
    {
      path: 'main',
      component: MainpageComponent
    },
    {
      path: 'message',
      component: ShowmessageComponent,
      children: [
        {
          path: 'ideal',
          component: IdealmessageComponent
        },
        {
          path: 'suitable',
          component: SuitablemessageComponent
        },
        {
          path: 'thebest',
          component: ThebestmessageComponent
        },
        {
          path: '',
          redirectTo: '/message/ideal',
          pathMatch: 'full'
        }
      ]
    },
    {
      path: 'login',
      component: LoginComponent
    },
    {
      path: 'register',
      component: RegisterComponent
    },
    {
      path: '',
      redirectTo: '/search',
      pathMatch: 'full'
    },
    {
      path: '**',
      component: ErrorpageComponent
    }
];

@NgModule({
  imports: [RouterModule.forRoot(routes)],
  exports: [RouterModule]
})
export class AppRoutingModule { }
